package com.doordu.framework.cloud.xxl.registry;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;

/**
 * 注册合约
 * @author zxw
 * @date 2020/9/21 14:16
 */
public class DoorduJobRegistry implements ServiceRegistry<DoorduJobRegistration> {

    private static final Log log = LogFactory.getLog(DoorduJobRegistry.class);

    @Override
    public void register(DoorduJobRegistration registration) {
        try {
            registration.getExecutorManager().getXxlJobExecutor().start();
        } catch (Exception e) {
            log.error("xxl-job start ERROR:{}", e);
        }
    }

    @Override
    public void deregister(DoorduJobRegistration registration) {
        registration.getExecutorManager().getXxlJobExecutor().destroy();
    }

    @Override
    public void close() {

    }

    @Override
    public void setStatus(DoorduJobRegistration registration, String status) {

    }

    @Override
    public <T> T getStatus(DoorduJobRegistration registration) {
        return null;
    }
}
